﻿using System;
using System.Collections.Generic;
using DispatchAssist.BusinessLogical.DAL;
using DispatchAssist.BusinessLogical.Model;
using CarolLib;
using System.Web;

namespace DispatchAssist.BusinessLogical.BLL
{
    public class SeatRoleManager
    {
        private static IDataProvider _provider;
        static log4net.ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        private readonly static string ALlRoleCacheKey = "ALlRoleCacheKey";

        public SeatRoleManager(IDataProvider dp)
        {
            _provider = new SqlDataProvider();
        }

        public static List<SeatRole> GetAllSeatRole()
        {
            List<SeatRole> list;
            if (!CacheHelper.TryGet<List<SeatRole>>(ALlRoleCacheKey, out list))
            {
                list = _provider.GetAllSeatRole();
                CacheHelper.Insert(ALlRoleCacheKey, list, 36000);
            }

            return list;
        }

        public static bool CreateSeatRole(SeatRole seatRole)
        {
            if(_provider.CreateSeatRole(seatRole))
            {
                CacheHelper.Remove(ALlRoleCacheKey);
                return true;
            }
            return false;
        }

        public static bool UpdateSeatRole(SeatRole seatRole)
        {
            return _provider.UpdateSeatRole(seatRole);
        }
        public static bool DeleteSeatRole(Guid roleID)
        {
            return _provider.DeleteSeatRole(roleID);
        }

    }
}
